﻿using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinForm_Mes.ProductManagement.BaseSetting
{
    public partial class AddTypeForm : DevExpress.XtraEditors.XtraForm
    {
        public AddTypeForm()
        {
            InitializeComponent();
            this.simpleButton1.Click += SimpleButton1_Click;
        }
        private async void SimpleButton1_Click(object sender, EventArgs e)
        {
            var param = new TypeModels
            {
                TypeCode = textEdit1.Text,
                TypeName = textEdit2.Text
            };
            //using (var client = new HttpClient())
            //{
            //    var url = "http://localhost:5164/api/Type/AddType";
            //    var apiResult = await client.PostAsync(url, param);
            //    if (apiResult.IsSuccessStatusCode)
            //    {
            //        XtraMessageBox.Show("新增成功！");
            //        this.DialogResult = DialogResult.OK; // 通知主窗口刷新
            //        this.Close();
            //    }
            //    else
            //    {
            //        string msg = await apiResult.Content.ReadAsStringAsync();
            //        XtraMessageBox.Show("新增失败：" + msg);
            //    }
            //}
        }
        public class TypeModels
        {
            /// <summary>
            /// 型号编码
            /// </summary>
            public string TypeCode { get; set; }
            /// <summary>
            /// 型号名称
            /// </summary>
            public string TypeName { get; set; }
            public string CreateUserId { get; set; } = "admin";
            public string UpdateUserId { get; set; } = "admin";
        }

        private void AddTypeForm_Load(object sender, EventArgs e)
        {

        }
    }
}